From: Juergen Gross Date: Fri, 4 Nov 2022 07:54:57 +0000 (+0100) Subject: xen: fix generated code for calling hypercall handlers X-Git-Tag: archive/raspbian/4.17.0-1+rpi1^2~33^2~40 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=9f3e585ff5ecc606e386057f5cfa66b22fea2b93;p=xen.git xen: fix generated code for calling hypercall handlers The code generated for the call_handlers_*() macros needs to avoid undefined behavior when multiple handlers share the same priority. The issue is the hypercall number being unverified fed into the macros and then used to set a mask via "mask = 1ULL << ". Avoid a shift amount of more than 63 by setting mask to zero in case the hypercall number is too large. Fixes: eca1f00d0227 ("xen: generate hypercall interface related code") Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Release-acked-by: Henry Wang --- diff --git a/xen/scripts/gen_hypercall.awk b/xen/scripts/gen_hypercall.awk index 34840c514f..9f7cfa298a 100644 --- a/xen/scripts/gen_hypercall.awk +++ b/xen/scripts/gen_hypercall.awk @@ -263,7 +263,7 @@ END { printf("#define call_handlers_%s(num, ret, a1, a2, a3, a4, a5) \\\n", ca); printf("({ \\\n"); if (need_mask) - printf(" uint64_t mask = 1ULL << num; \\\n"); + printf(" uint64_t mask = (num) > 63 ? 0 : 1ULL << (num); \\\n"); printf(" "); for (pl = 1; pl <= n_prios[ca]; pl++) { if (prios[ca, p_list[pl]] > 1) {